package com.linzelin.po;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.lang.Nullable;

public class People {


    /*注意这里使用的@Autowired注解配置的属性
     * 名字要和对应的xml中bean的名字相同
     * 不然就会报错*/
    @Autowired(required = false)
    @Qualifier("dog222")
    /*给这个autowired加上一个false的话
     * 表示给这个属性赋值可以为空,如果是true的就不允许null
     * 会报错*/
    private Cat cat;
    @Autowired
    private Dog dog;

    private String name;

    public People(@Nullable String name) {
        //使用这个注解可以让构造函数传递空值
        this.name = name;
    }

    @Override
    public String toString() {
        return "People{" +
                "cat=" + cat +
                ", dog=" + dog +
                ", name='" + name + '\'' +
                '}';
    }

    public Cat getCat() {
        return cat;
    }

    public void setCat(Cat cat) {
        this.cat = cat;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
